﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AgencyEntityLib.BaseEntity;
using Ecopsy.Tools;

/// <summary>
/// Summary description for ContractSurfaceItemExt
/// </summary>
/// 
namespace AgencyEntityLib.BaseEntity
{
    public static class ContractSurfaceItemExt
    {
      

        /// <summary>
        /// Представление записи ContractSurfaceItem   в грднике
        /// </summary>
        public class grdContractSurfaceItem
        {
            private ContractSurfaceItem _Source;
            wsConstractions ws_Constractions = (wsConstractions)GlobalConstants.CurrentAgency.WS_FactoryList[WS_FactoryList.wsKey_Constraction];            
            public grdContractSurfaceItem(ContractSurfaceItem Source)
            {
                _Source = Source;
                // установить номер в очереди
                SetSurface_QNumber(_Source);
            }
            public grdSide grdSide
            {
                get
                {

                    Constraction c = ws_Constractions.GetConstractionFromSideId(_Source.SideID);
                    Side s = (Side)c.SideList[_Source.SideID];
                    SideLst.SideItemBox s1 = new SideLst.SideItemBox() { Constraction = c, Side = s };
                    return new grdSide(s1);
                }
            }
            public string ID { get { return _Source .ID ; } }
            public string Litera { get { return grdSide.Litera; } }
            public string GID { get { return grdSide.ConstractionNumber; } }
            public string ConstractionType { get { return grdSide.ConstractionTypeName; } }
            public string FullAdress { get { return grdSide.FullAdress; } }
            public int Price { get { return grdSide.Price; } }
            public int ConractPrice { get { return _Source.ConractPrice; } }            
            public DateTime DtStart { get{return _Source .DtStart; }}
            public DateTime DtFinish { get { return _Source.DtFinish; } }
            public bool IsPrioritetLevel 
            {
                get { return _Source.qPrioritetLevel > 0; } 
            }
            public int DayLen { get { return DateTimeTools.GetDayDiff(DtFinish, DtStart); } }
            public int Summa 
            {
                get { return Ecopsy.Tools.DateTimeTools.GetDayDiff(DtFinish, DtStart) * ConractPrice; } 
            }

            /// <summary>
            /// Признак находиться ли поверхность в очереди.
            /// </summary>
            public bool In_Q 
            { 
                    get { return _Source.SurfaceNumber > grdSide.Side.SurfaceCount-1; } 
            }
            public int qNum
            {
                get
                {
                    return _Source.SurfaceNumber;
                }
            }

        }

        public static void SetSurface_QNumber(this ContractSurfaceItem _ContractSurfaceItem)
        {
            ws_Hints ws = new ws_Hints();
            ws.SetSurface_QNumber(ref _ContractSurfaceItem);
        }
    }

     

}